package com.sneaker.shower.entity.dto;

import com.google.common.collect.Lists;
import com.sneaker.shower.entity.enums.UserTypeEnum;
import com.sneaker.shower.util.JacksonUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
@ApiModel("会员充值等级")
public class MemberLevelDTO {
    @ApiModelProperty("普通会员")
    private List<ChargeInfo> normalList;

    @ApiModelProperty("黑卡会员")
    private List<ChargeInfo> blackList;

    public static MemberLevelDTO get() {
        List<ChargeInfo> normalList = Lists.newArrayList();
        List<UserTypeEnum> normalType = UserTypeEnum.getByLevel(1);
        normalType.forEach(userTypeEnum ->
                normalList.add(ChargeInfo.builder()
                        .message("充 " + userTypeEnum.getPrice() + " 享 " + userTypeEnum.getDiscount().multiply(new BigDecimal(10)).setScale(1) + " 折")
                        .type(userTypeEnum.getCode()).build())
        );
        List<ChargeInfo> blackList = Lists.newArrayList();
        List<UserTypeEnum> blackType = UserTypeEnum.getByLevel(2);
        blackType.forEach(userTypeEnum ->
                blackList.add(ChargeInfo.builder()
                        .message("充 " + userTypeEnum.getPrice() + " 享 " + userTypeEnum.getDiscount().multiply(new BigDecimal(10)).setScale(1) + " 折")
                        .type(userTypeEnum.getCode()).build())
        );
        MemberLevelDTO memberLevelDTO = new MemberLevelDTO();
        memberLevelDTO.setNormalList(normalList);
        memberLevelDTO.setBlackList(blackList);
        return memberLevelDTO;
    }

    public static void main(String[] args) {
        System.out.println(JacksonUtils.writeValueAsString(get()));
    }
}
